<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>寝室管理后台首页</title>
    <link rel="stylesheet" type="text/css"  href="/DMS/PHP-DMS/lib/jeasyui/1.7.5/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/DMS/PHP-DMS/lib/jeasyui/1.7.5/themes/icon.css">
    <script type="text/javascript"  src="/DMS/PHP-DMS/lib/jquery/1.12.4/jquery.min.js"></script>
    <script type="text/javascript"  src="/DMS/PHP-DMS/lib/jeasyui/1.7.5/jquery.easyui.min.js"></script>
</head>
<body class="easyui-layout">
<div data-options="region:'north',split:true" style="height:70px;">
    <div> <h2>重庆信息技术职业学院寝室管理系统</h2></div>

</div>
<div data-options="region:'west',title:'West',split:true" style="width:200px;">
    <div id="menuAccordion"></div>
</div>
<div id="tab" class="easyui-tabs"  data-options="region:'center'" fit="true" style="background:#eee;">

</div>

<script>
    $(function() {
        // 初始化
        $('#menuAccordion').accordion({
            fillSpace: true,
            fit: true,
            border: false,
            animate: false
        });

        $.post("/DMS/PHP-DMS/sj.json", {type: 1}, function(data) {
            if(data) {
                $.each(data, function(index, item) {
                    var selected = false;
                    if (index == 0) {
                        selected = true;
                    }

                    $('#menuAccordion').accordion('add', {
                        title: item.text,
                        content: "<ul id='menu_tree_" + item.id + "'></ul>",
                        selected: selected
                    });

                    $('#menu_tree_' + item.id).tree({
                        data: item.children,
                        onClick: function(node) {
                            if (node.children.length != 0) {
                                return;
                            }
                            addTab('tab', node.text, node.url);
                        }
                    });
                });
            }
        }, 'json');
    });

    function addTab(tabname, title, url) {
        var $tab = $('#' + tabname);
        if($tab.tabs('exists', title)) {
          $tab.tabs("select",title);
        }

        else {
            $tab.tabs('add', {
                title: title,
                href: url,
                closable: true,
                bodyCls:"content"
            })
        }

    }
</script>

</body>
</html>